<?php

require_once('Classes/Datasources/Filters/Filter_TableStartsWith.php');


class Test_Filter_TableStartsWith extends UnitTestCase {
    
    function test_ShouldIncludeTableReturnsTrueIfThePassedStringStartsWithTheStringGivenInTheConstructor() {
    	$oFilter = new Filter_TableStartsWith( 'This' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'ThisIsTrue' ) );
    }

    function test_ShouldIncludeTableReturnsTrueIfThePassedStringIsExactlyTheSameAsTheStringGivenInTheConstructor() {
    	$oFilter = new Filter_TableStartsWith( 'ThisIsTrue' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'ThisIsTrue' ) );
    }

    function test_ShouldIncludeTableReturnsTrueIfThePassedStringStartsWithTheStringGivenInTheConstructorEvenIfTheCaseDoesNotMatch() {
    	$oFilter = new Filter_TableStartsWith( 'This' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'THISISTRUE' ) );

    	$oFilter = new Filter_TableStartsWith( 'THIS' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'thisistrue' ) );
    }

    function test_ShouldIncludeTableReturnsFalseIfThePassedStringDoesNotStartsStringGivenInTheConstructor() {
    	$oFilter = new Filter_TableStartsWith( 'That' );
        $this->assertFalse(  $oFilter->ShouldIncludeTable( 'ThisIsNotTrue' ) );
    }

    function test_ShouldIncludeTableAlwaysReturnsTrueIfTheStringGivenInTheConstructorIsEmpty() {
    	$oFilter = new Filter_TableStartsWith( '' );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'ThisIsTrue' ) );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( 'THISISTRUE' ) );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( '' ) );
        $this->assertTrue(  $oFilter->ShouldIncludeTable( '678432y7r87yfv' ) );
    }
    
    function test_ShouldIncludeTableReturnsFalseIfTheStringPassedIsShorterThanThatGivenInTheConstructor() {
    	$oFilter = new Filter_TableStartsWith( 'SomeText' );
        $this->assertFalse( $oFilter->ShouldIncludeTable( 'Some' ) );
        $this->assertFalse( $oFilter->ShouldIncludeTable( 'SomeTex' ) );
    }

    function test_ShouldIncludeTableIgnoresWhitespaceAtTheStartOfBothStringsBeingCompared() {
    	$oFilter = new Filter_TableStartsWith( '  	SomeText' );
        $this->assertTrue( $oFilter->ShouldIncludeTable( 'SomeTextThing' ) );
    	$oFilter = new Filter_TableStartsWith( 'SomeText' );
        $this->assertTrue( $oFilter->ShouldIncludeTable( '	   SomeTextThing' ) );
    }


}

?>
